﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Table = FCNS.Data.Table;

namespace DoubleH.Utility
{
   public class NormalUtility
    {
       /// <summary>
       /// 显示登录窗体并且是否登录成功
       /// </summary>
       /// <returns></returns>
      public static bool ShowLoginWindowSuccess()
       {
           Table.UserS.LoginUser = null;
           DoubleH.Utility.LoginWindow lw = new Utility.LoginWindow();
           lw.ShowDialog();
           return Table.UserS.LoginUser != null;
       }
       /// <summary>
       /// 加载虚拟键盘
       /// </summary>
       public void LoadOSK()
       {
           MessageWindow.Show(Environment.GetFolderPath(Environment.SpecialFolder.System));
           MessageWindow.Show(Environment.GetFolderPath(Environment.SpecialFolder.SystemX86));

           //Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.SystemX86) + "osk.exe");
       }


       public delegate bool EqualsComparer<T>(T x, T y);
       public class Compare<T> : IEqualityComparer<T>
       {
           private EqualsComparer<T> _equalsComparer;

           public Compare(EqualsComparer<T> equalsComparer)
           {
               this._equalsComparer = equalsComparer;
           }

           public bool Equals(T x, T y)
           {
               if (null != this._equalsComparer)
                   return this._equalsComparer(x, y);
               else
                   return false;
           }
           public int GetHashCode(T obj)
           {
               return obj.ToString().GetHashCode();
           }
       }
       ///// <summary>
       ///// MD5加密
       ///// </summary>
       //public static string GetMd5Hash(string input)
       //{
       //    var md5Hasher = MD5.Create();
       //    var data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));

       //    var sBuilder = new StringBuilder();

       //    foreach (var t in data)
       //    {
       //        sBuilder.Append(t.ToString("X2"));
       //    }

       //    return sBuilder.ToString();
       //}

       ///// <summary>
       ///// MD5密码验证
       ///// </summary>
       //public static bool VerifyMd5Hash(string input, string hash)
       //{
       //    var hashOfInput = GetMd5Hash(input);
       //    var comparer = StringComparer.OrdinalIgnoreCase;
       //    return 0 == comparer.Compare(hashOfInput, hash);
       //}
    }
}
